﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jifencenter.aspx.cs" Inherits="jmwqz.jifencenter" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8">
<title>积分中心</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- Mobile Devices Support @begin -->
<meta content="application/xhtml+xml; charset=utf-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- Mobile Devices Support @end -->
<link rel="stylesheet" type="text/css" href="/styles/ui.css">
<link rel="stylesheet" type="text/css" href="/styles/style.css">
<link rel="stylesheet" type="text/css" href="/styles/attract-fans-mobile.css">
<script type="text/javascript" src="/scripts/jquery/jquery-1.10.2.min.js"></script>
<!-- Gem style -->
<%--<style>
	.top { text-align: center; font-size: 18px; margin: 10px; background-color: #EFC371;}
	.top a{ color:#fff; }
	button.disabled
	{ background-color: #999 !important; border: 1px solid #999 !important;
	} .score1 { color: green; } .score0 { color: red; } .goods { margin: 0
	auto; width: 100%; } .goodslist { margin: 0 auto; padding: 10px; margin:
	10px; background: #fff; border: 1px solid #e0e0e0; border-radius: 3px;
	-moz-border-radius: 3px; /* Old Firefox */ } .goodslist img { width: 100%;
	} .goodslist h4 { font-size: 16px; line-height: 24px; color: #232323; font-weight:
	500; margin-top: 10px; margin-bottom: 10px; } .goodslist h5 { font-size:
	16px; line-height: 24px; color: #999; font-weight: normal; margin-top:
	10px; margin-bottom: 10px; } .goodsopbtn { text-align: center; color: #1956ba;
	font-size: 16px; } .goodsopbtn a { color: #1956ba; } .sbtn { border: 0px
	solid red; border-radius: 5px; background: #05B905; color: #fff; line-height:
	32px; padding: 3px; text-align: center; font-size: 16px; margin-bottom:
	5px; } .sbtn a { color: #fff; } .nbtn { border: 1px solid #959595; border-radius:
	5px; background: #959595; color: #fff; line-height: 32px; padding: 3px;
	text-align: center; font-size: 16px; margin-bottom: 5px; } .nbtn a { color:
	#fff; } .dk { padding-left: 30px; } .color1 { color: #e04f00 } .color2
	{ color: #e04f00; } .goodslist p { margin: 0 auto; width: 100%; }
</style>--%>
<style>
   .button {
	display: inline-block;
	position: relative;
	text-align: center;
	text-decoration: none;
	font: bold 16px/25px Arial, sans-serif;

	text-shadow: 1px 1px 1px rgba(255,255,255, .22);

	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
    margin-left:20px;
    margin-bottom:10px;
	-webkit-box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1px rgba(255,255,255, .44);
	-moz-box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1px rgba(255,255,255, .44);
	box-shadow: 1px 1px 1px rgba(0,0,0, .29), inset 1px 1px 1px rgba(255,255,255, .44);

	-webkit-transition: all 0.15s ease;
	-moz-transition: all 0.15s ease;
	-o-transition: all 0.15s ease;
	-ms-transition: all 0.15s ease;
	transition: all 0.15s ease;
}
</style>
<script type="text/javascript">
    $(function () {
        updateGood();
    });
    function updateGood() {
        $.ajax({
            type: "Post",
            async: true,
            dataType: 'json',
            url: "ajax/good.ashx?myact=getlist",
            cache: false,
            success: function (data) {
                if (data == "1") {
                    return;
                } else {
                    $.each(data, function (i, item) {
                        additem(i, item, data);
                    })
                }
            }
        });
    };
    function additem(i, item, data) {
        $('.commodity-list ul').append("<li style='margin:0 30px;border-top:1px dashed #ccc' data-score='"+ data[i].price  +"' data-id='"+ data[i].id + "'></li>");
        $(".commodity-list ul li:last").append("<img style='width:30%;' src='" + data[i].img_thumb + "'>");
        $('.commodity-list ul li:last').append("<div style='display:inline-block;width:70%;'></div>");
        $('.commodity-list ul li:last div').append("<p style='margin-left:10px;font-size:15px;word-break:break-all;'>" + data[i].name + "</p>");
        $('.commodity-list ul li:last div').append("<p style='margin-left:10px;color:red;word-break:break-all;font-size:13px;'>" + data[i].summary + "</p>");
        $('.commodity-list ul li:last div').append("<p style='margin-left:10px;' class='red'>" + data[i].price + "积分</p>");
        $('.commodity-list ul li:last div').append("<span style='margin-left:10px;'>￥" + data[i].cost + "</span>");
        $('.commodity-list ul li:last div').append("<span style='margin-left:20px;font-size:12px;'>库存 " + data[i].stock + "</span>");
        if (parseFloat('<%= GetJifen() %>') >= parseFloat(data[i].price)) {
            if (parseInt(data[i].stock) < 1) {
                $('.commodity-list ul li:last div').append("<a  href='javascript:void(0);' class='button banduihuan' data-role='confirm' class='disabled'>禁止兑换</a>")
            }
            else {
                $('.commodity-list ul li:last div').append("<a class='button duihuan' style='background-color:red;color:#FFF;float:right;text-align:center;' data-role='confirm' class='enabled'>立即兑换</a>");
            }
         }
         else{
             $('.commodity-list ul li:last div').append("<a  href='javascript:void(0);' class='button banduihuan' data-role='confirm' class='disabled'>积分不足</a>")
         }
         $('.duihuan').unbind('click').click(function (e) {
             submit($(this).parent().parent().attr("data-id"));
             e.preventDefault();
         });  
    }
    function submit(id) {
         $.ajax({
             type: "Post",
            async: false,
            dataType: 'json',
            url: "ajax/good.ashx?myact=duihuan&id=" + id,
            cache: false,
            success: function (data) {
                if(data == "2"){
                    alert("未完善地址,请先修改地址");
                    window.location = "editaddr.aspx";
                }
                else if (data == "1") {
                    return;
                } else {
                    alert("兑换成功");
                    window.location = "/jifencenter.aspx";
                }
            }
        }); 
    }
</script>
</head>
<body>
	<div class="wrp">
		<div id="js_main" class="profile_hd">
			<div class="inner">
				<img class="profile_logo" src="<%= GetHeadImg()%>" />
				<div class="profile_name"><%=GetNickName() %></div>
				<div class="profile_extra">
					<span class="verify_name">关注时间：<% =GetGzDate() %></span>
				</div>
				<div class="data_overview">
					<ul class="overview_list">
						<li class="overview_item">
							<p class="desc r_line">推广数</p>
							<p class="number"><%=GetTj_num() %></p>
						</li>
						<li class="overview_item">
							<p class="desc">总积分</p>
							<p class="number"><%= GetJifen() %></p>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="profile_fun">
			<ul id="js_menu" class="menu_list">
				<li class="menu_item fans_record">
					<a href="/duihuan.aspx" class="inner_item">
						<span class="icon_menu"></span>
						<p class="text_menu">兑换记录</p>
					</a>
				</li>
				<li class="menu_item swap_record">
					<a href="#" class="inner_item">
						<span class="icon_menu"></span>
						<p class="text_menu">兑换中心</p>
					</a>
				</li>
				<li class="menu_item rank_record">
					<a href="pai.aspx" class="inner_item">
						<span class="icon_menu"></span>
						<p class="text_menu">积分排行</p>
					</a>
				</li>
                <li class="menu_item fans_record">
					<a href="editaddr.aspx" class="inner_item">
						<span class="icon_menu"></span>
						<p class="text_menu">收货地址</p>
					</a>
				</li>
			</ul>
		</div>
		<div class="goods" style="margin-top:20px;">
			<div class="commodity-list">
                <ul>
<%--                   <li data-score="5" data-id="123">
                      <img src="">
                      <div class="desc">饼干
                         <span class="score read">5</span>"积分"
                      </div>
                      <div class="price">￥5</div>
                      <div class="amount">库存 87</div>
                      <button data-role="confirm" class="enabled">立即兑换</button>
                   </li>--%>
                </ul>						
			</div>
		</div>
	</div>
</body>
</html>

<%--				<h2><img style="width:100%;height:320px" alt="图片" src='<%= GetGood_Img() %>' />
				</h2>
				<h4><%= GetGood_Name() %></h4>
				<h5>剩余数量：<font style="margin-right:50px"><%= GetGood_Stock()%></font>
					价值：<font>￥ <%= GetGood_Cost()%></font>
					<br/>
					消耗积分：<font style="margin-right:50px"><%= GetGood_Price()%></font>
					<br/>
					截止日期：<font><%= GetGood_ExpireDate()%></font>
				</h5>	--%>	
